﻿
namespace NRemedy
{

    public class GetARFieldFilterDelegate : IGetARFieldFilterDelegate
    {
        #region defined field filter

        public static bool FieldFilterBase(BMC.ARSystem.Field field)
        {
            if (field == null) return false;
            return true;
        }

        public static bool FieldFilterIsDataField(BMC.ARSystem.Field field)
        {
            return field.IsDataField();
        }

        public static bool FieldFilterIsIntegerField(BMC.ARSystem.Field field)
        {
            return field.DataType == 2u;
        }

        public static bool FieldFilterIsRealField(BMC.ARSystem.Field field)
        {
            return field.DataType == 3u;
        }

        public static bool FieldFilterIsCharacterField(BMC.ARSystem.Field field)
        {
            return field.DataType == 4u;
        }

        public static bool FieldFilterIsDiaryField(BMC.ARSystem.Field field)
        {
            return field.DataType == 5u;
        }

        public static bool FieldFilterIsSelectionField(BMC.ARSystem.Field field)
        {
            return field.DataType == 6u || field.DataType == 8u;
        }

        public static bool FieldFilterIsDateTimeField(BMC.ARSystem.Field field)
        {
            return field.DataType == 7u;
        }

        public static bool FieldFilterIsDecimalField(BMC.ARSystem.Field field)
        {
            return field.DataType == 10u;
        }

        public static bool FieldFilterIsAttachmentField(BMC.ARSystem.Field field)
        {
            return field.DataType == 11u;
        }

        public static bool FieldFilterIsCurrencyField(BMC.ARSystem.Field field)
        {
            return field.DataType == 12u;
        }

        public static bool FieldFilterIsDateOnlyField(BMC.ARSystem.Field field)
        {
            return field.DataType == 13u;
        }

        public static bool FieldFilterIsTimeOnlyField(BMC.ARSystem.Field field)
        {
            return field.DataType == 14u;
        }

        public static bool FieldFilterIsReservedField(BMC.ARSystem.Field field)
        {
            return field.IsCoreField;
        }

        #endregion

        public ARFieldFilterDelegate getARFieldFilterDelegate()
        {
            return new ARFieldFilterDelegate(filterIsDataFieldOrReservedField);
        }

        private bool filterIsDataFieldOrReservedField(BMC.ARSystem.Field field)
        {
            return GetARFieldFilterDelegate.FieldFilterIsDataField(field) && !GetARFieldFilterDelegate.FieldFilterIsReservedField(field);
        }
    }
}
